const browser = require('../browser');
const { logger } = require('../../utils/logger');

class PuppeteerClick {
  static async click(url, selector, options = {}) {
    return browser.runWithPuppeteer(url, options, async (page) => {
      await page.waitForSelector(selector);
      await page.click(selector);
      
      logger.info(`Puppeteer点击成功: ${url} -> ${selector}`);
      
      return {
        success: true,
        url,
        selector,
        timestamp: new Date().toISOString()
      };
    });
  }
}

module.exports = PuppeteerClick;
